package com.yunyi.web.controller.makeapp;

import com.yunyi.common.core.domain.AjaxResult;
import com.yunyi.common.utils.SecurityUtils;
import com.yunyi.system.domain.EmrCase;
import com.yunyi.system.domain.EmrCaseSlide;
import com.yunyi.system.service.EmrCaseService;
import com.yunyi.system.service.EmrCaseSlideService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;

@Api(tags = "预约切片")
@RestController
public class makeappController {
    @Resource
    EmrCaseSlideService emrCaseSlideService;

    @Resource
    EmrCaseService emrCaseService;

    /**
     * 根据条件模糊查询预约切片
     * @param pageSize 每页显示的条目
     * @param pageNum  默认页面页码
     * @param condition 查询条件
     * @return
     */
    @ApiOperation("模糊查询预约切片")
    @GetMapping("selectAllBycondition")
    public AjaxResult selectAllBycondition(@RequestParam(defaultValue = "10") Integer pageSize,
                                           @RequestParam(defaultValue = "1") Integer pageNum,
                                           Integer apmstatus,
                                           String condition){
        return emrCaseSlideService.listALlBycondition(pageSize, pageNum, apmstatus, condition);
    }

    /**
     * 修改预约状态
     * @param Id
     * @return
     */
    @ApiOperation("修改状态")
    @PutMapping("update")
    public AjaxResult updateapmstatusById(String Id,String apmstatus){
        AjaxResult ajaxResult = emrCaseSlideService.updateapmstatusById(Id, apmstatus);
        System.out.println(ajaxResult);
        return  ajaxResult;
    }

    @ApiOperation("根据id删除预约信息")
    @DeleteMapping("deleteByid")
    public AjaxResult deleteByid(String id){
        return emrCaseSlideService.deleteById(id);
    }


    @ApiOperation("根据id删除病例信息")
    @DeleteMapping("deeleteByidEmrcase")
    public AjaxResult deeleteByidEmrcase(String id){
        return emrCaseService.deleteById(id);
    }

    /**
     * 新增病例
     * @param emrCase
     * @return
     */
    @PostMapping("saveByEmrCase")
    @ApiOperation("新增病例")
    public AjaxResult saveByEmrCase(@RequestBody EmrCase emrCase){
        System.out.println(emrCase);
        return emrCaseService.saveByEmrCase(emrCase);
    }

    /**
     * 获取当前用户名
     * @return
     */
    @ApiOperation("获取当前用户")
    @GetMapping("GetUserName")
    public String GetUserName(){
        return  SecurityUtils.getUsername();
    }

    /**
     * 获取医生id
     * @return
     */
    @ApiOperation("获取医生ID")
    @GetMapping("GetDoctorId")
    public String GetDoctorId(){
      return  SecurityUtils.getUserId().toString();
    }

    /**
     * 新增预约
     * @param emrCaseSlide
     * @return
     */
    @ApiOperation("新增预约切片")
    @PostMapping("insertEmrCaseSide")
    public AjaxResult insertEmrCaseSide(EmrCaseSlide emrCaseSlide){
        return emrCaseSlideService.insertCaseSide(emrCaseSlide);
    }


}
